<template>
  <div>
    <header class="head">连接线配置</header>
    <el-form label-width="100px">
      <el-form-item label="默认分支：">
        <el-checkbox
          v-model="formData.isDefault"
          :disabled="isView"
          @change="handleDefault"
        ></el-checkbox>
      </el-form-item>
      <el-form-item label="分支条件：">
        <el-input
          v-model="formData.rule"
          :disabled="isView"
          type="textarea"
          placeholder="请输入分支条件"
          style="width: 100%"
          @change="handleRule"
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "custom-line",
  props: {
    fbOptions: {
      type: Object,
      default: () => {
      }
    },
  },
  computed: {
    formData: {
      get() {
        return this.fbOptions.flow.moreNodeInfo[this.fbOptions.flow.currentNodeId] || {};
      },
      set(val) {
        this.fbOptions.flow.moreNodeInfo = {
          ...this.fbOptions.flow.moreNodeInfo,
          [this.fbOptions.flow.currentNodeId]:val|| {},
        }
      },
    },
    isView() {
      return (
        this.fbOptions.operationType === "view"
      );
    },
  },
  methods: {
    handleDefault(val) {
      if (val) {
        this.fbOptions.flow.selectNode.setLabels("默认");
      } else {
        this.fbOptions.flow.selectNode.setLabels("");
      }
    },
    handleRule() {
      this.fbOptions.flow.selectNode.setLabels(this.formData.rule);
    },
  },
};
</script>

<style lang="scss" scoped>
.head {
  height: 40px;
  text-align: center;
  line-height: 40px;
  color: #333;
  font-weight: bold;
  font-size: 14px;
  background-color: #ccc;
  margin-bottom: 16px;
}
.el-form-item {
  margin-bottom: 0px;
}
</style>
